<?php
/**
 * Created By base
 * Author: Virus
 * Date: 2020/3/19
 * Time: 17:53
 */

if (!function_exists('check_auth')) {
    /**
     * @param $url
     * @return bool
     */
    function check_auth($url)
    {
        $auth = new \liliuwei\think\Auth();

        if (session('is_admin') == 1) {
            return true;
        } else {
            return $auth->check($url, session('uid'));
        }
    }
}

if (!function_exists('format_size')) {
    /**
     * 格式化输出数据大小
     * @param $size
     * @return string
     */
    function format_size($size)
    {
        $arr = ['B', 'KB', 'MB', 'GB', 'TB'];
        $i   = 0;
        while ($size >= 1024) {
            $size = $size / 1024;
            $i++;
        }

        return round($size, 4).$arr[$i];
    }
}